package io.adrainty.demo.seata.storage.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.adrainty.demo.seata.storage.mapper.StorageMapper;
import io.adrainty.demo.seata.storage.models.bo.StorageBO;
import io.adrainty.demo.seata.storage.service.IStorageService;
import io.adrainty.demo.seata.storage.tcc.IStorageTCC;
import io.seata.spring.annotation.GlobalTransactional;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

/**
 * @author AdRainty
 * @version V1.0.0
 * @since 2025/8/21 上午12:28
 */

@Slf4j
@Service
public class StorageServiceImpl extends ServiceImpl<StorageMapper, StorageBO> implements IStorageService {

    @Resource
    private IStorageTCC storageTCC;

    @Override
    @GlobalTransactional
    public boolean doShop(String accountNo, Long productId, Long skuId, Integer count) {
        return storageTCC.prepare(null, accountNo, productId, skuId, count);
    }

}
